import request from "@/utils/request";
let url = "/project";
// http://{{myhost}}:8000/project/projectIterationExtension?tag_type=0

export function download(params) {
  if (!params || params.length < 1) return;

  return request({
    url: "/download/projectIterationExtension",
    method: "post",
    data: params,
    responseType: "blob",
  });
}

export function downloadSub(params) {
  if (!params || params.length < 1) return;

  return request({
    url: "/download/subsystemIterationExtension",
    method: "post",
    data: params,
    responseType: "blob",
  });
}
// http://{{myhost}}:8000/download/versionIterationExtension
export function downloadVer(params) {
  if (!params || params.length < 1) return;

  return request({
    url: "/download/versionIterationExtension",
    method: "post",
    data: params,
    responseType: "blob",
  });
}

export function projectIterationExtension(params) {
  if (!params) params = "?tag_type=0";

  return request({
    url: url + "/projectIterationExtension" + params,
    method: "get",
  });
}

export function subsystemIterationExtension(params) {
  if (!params) return;

  return request({
    url: url + "/subsystemIterationExtension?project_id=" + params,
    method: "get",
  });
}
// http://{{myhost}}:8000/project/subsystemBugPlot?subsystem_id=504&date_range=7&month_num=6
// Bug 趋势图
export function subsystemBugPlot(params) {
  // return {
  //   "data": {
  //     "system_version_extension": [
  //       {
  //         "mouth": "8月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "9月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "10月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "11月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "12月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "1月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 1
  //       }
  //     ],
  //     "date_range": 7,
  //     "subsystem_id": 504,
  //     "month_num": 6
  //   }
  // }
  if (!params) return;

  return request({
    url:
      url + "/subsystemBugPlot?date_range=7&month_num=6&subsystem_id=" + params,
    method: "get",
  });
}
// http://{{myhost}}:8000/project/subsystemIterationPlot?subsystem_id=504&date_range=7&month_num=6
// 迭代版本 趋势图
export function subsystemIterationPlot(params) {
  // return {
  //   "data": {
  //     "subsystem_version_extension": [
  //       {
  //         "mouth": "8月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "9月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "10月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "11月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "12月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       },
  //       {
  //         "mouth": "1月",
  //         "Bug_trend_histogram_add_num": 0,
  //         "Bug_trend_line_closed_num": 0
  //       }
  //     ],
  //     "date_range": 7,
  //     "subsystem_id": 504,
  //     "month_num": 6
  //   }
  // }
  if (!params) return;

  return request({
    url:
      url +
      "/subsystemIterationPlot?date_range=7&month_num=6&subsystem_id=" +
      params,
    method: "get",
  });
}

// http://{{myhost}}:8000/subsystem/subsystemIterationVersionExtension?subsystem_id=282
export function subsystemIterationVersionExtension(params) {
  // return {
  //   "data": {
  //     "iteraction_version_extension": [
  //       {
  //         "version_id": 669,
  //         "version_name": "数据汇聚系统P2",
  //         "plan_cycle": [
  //           "\"2022-03-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 1,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 747,
  //         "version_name": "中心云门户P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 768,
  //         "version_name": "136项目管理P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 818,
  //         "version_name": "高精度定位服务系统P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 1,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 819,
  //         "version_name": "时空匹配定位系统P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "closed",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 820,
  //         "version_name": "动态高精度地图维护与服务P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "closed",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 821,
  //         "version_name": "基础支撑P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 822,
  //         "version_name": "地图数据P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 823,
  //         "version_name": "测试P2",
  //         "plan_cycle": [
  //           "\"2022-04-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 109,
  //         "dev_leader": "yanghongzhan",
  //         "test_leader": "wurui",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       },
  //       {
  //         "version_id": 974,
  //         "version_name": "中移动态地图服务",
  //         "plan_cycle": [
  //           "\"2022-08-01\"",
  //           "\"2022-08-31\""
  //         ],
  //         "plan_date_duration": 23,
  //         "dev_leader": "wangtingyi",
  //         "test_leader": "yangtao",
  //         "unsolved_bug_total": 0,
  //         "this_day_bug_add": 0,
  //         "execute_progress": -1,
  //         "execute_status": "doing",
  //         "remark": ""
  //       }
  //     ],
  //     "subsystem_id": 282
  //   }
  // }
  if (!params) return;

  return request({
    url: "/subsystem/subsystemIterationVersionExtension?subsystem_id=" + params,
    method: "get",
  });
}

// http://{{myhost}}:8000/subsystem/IterationBugPlot?version_id=669&date_range=7&month_num=6
export function IterationBugPlot(params) {
  return {
    data: {
      iteraction_version_plot: [
        {
          mouth: "8月",
          Bug_trend_histogram_add_num: 0,
          Bug_trend_line_closed_num: 0,
        },
        {
          mouth: "9月",
          Bug_trend_histogram_add_num: 0,
          Bug_trend_line_closed_num: 0,
        },
        {
          mouth: "10月",
          Bug_trend_histogram_add_num: 0,
          Bug_trend_line_closed_num: 0,
        },
        {
          mouth: "11月",
          Bug_trend_histogram_add_num: 0,
          Bug_trend_line_closed_num: 0,
        },
        {
          mouth: "12月",
          Bug_trend_histogram_add_num: 0,
          Bug_trend_line_closed_num: 0,
        },
        {
          mouth: "1月",
          Bug_trend_histogram_add_num: 0,
          Bug_trend_line_closed_num: 0,
        },
      ],
      date_range: 7,
      version_id: 669,
      month_num: 6,
    },
  };

  if (!params) return;

  return request({
    url:
      "/subsystem/IterationBugPlot?date_range=7&month_num=6&version_id=" +
      params,
    method: "get",
  });
}

// http://{{myhost}}:8000/subsystem/IterationCasePlot?version_id=669&date_range=7&month_num=6
export function IterationCasePlot(params) {
  return {
    data: {
      version_case_trend_histogram: [
        {
          mouth: "8月",
          case_pass: 0,
          case_failed: 0,
          case_blocked: 0,
        },
        {
          mouth: "9月",
          case_pass: 0,
          case_failed: 0,
          case_blocked: 0,
        },
        {
          mouth: "10月",
          case_pass: 0,
          case_failed: 0,
          case_blocked: 0,
        },
        {
          mouth: "11月",
          case_pass: 0,
          case_failed: 0,
          case_blocked: 0,
        },
        {
          mouth: "12月",
          case_pass: 0,
          case_failed: 0,
          case_blocked: 0,
        },
        {
          mouth: "1月",
          case_pass: 0,
          case_failed: 0,
          case_blocked: 0,
        },
      ],
      date_range: 7,
      version_id: 669,
      month_num: 6,
    },
  };
  if (!params) return;

  return request({
    url:
      "/subsystem/IterationCasePlot?date_range=7&month_num=6&version_id=" +
      params,
    method: "get",
  });
}

export function test(params) {
  if (!params) return;

  return request({
    url: url + "/projectIterationExtension" + params,
    method: "get",
  });
}
